﻿<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:uc="clr-namespace:SqlMiM.Common.UserControls.PerfGraph;assembly=SqlMiM.Common"             
    xmlns:conv="clr-namespace:SqlMiM.Common.Converters;assembly=SqlMiM.Common"
    xmlns:chartingToolkit="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit" 
    xmlns:visualizationToolkit="clr-namespace:System.Windows.Controls.DataVisualization;assembly=System.Windows.Controls.DataVisualization.Toolkit" 
    xmlns:System_Windows_Controls_DataVisualization_Charting_Primitives="clr-namespace:System.Windows.Controls.DataVisualization.Charting.Primitives;assembly=System.Windows.Controls.DataVisualization.Toolkit" 
    xmlns:vsm="clr-namespace:System.Windows;assembly=WPFToolkit" x:Class="SqlMiM.SqlServer.Server2008.View"
    MinHeight="200"
    Loaded="UserControl_Loaded">

    <UserControl.Resources>

        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/SqlMiM.Common;component/Resources/ControlsTheme.xaml"/>
            </ResourceDictionary.MergedDictionaries>

            <conv:BooleanToVisibilityConverter x:Key="VisibleIfTrue" Inverted="True" Not="False"    />
            <conv:BooleanToVisibilityConverter x:Key="VisibleIfNotTrue" Inverted="True" Not="True"    />
            <conv:TimeSpanConverter x:Key="TimeSpanConverter" />

            <sys:TimeSpan x:Key="graphDuration" >0:1:1</sys:TimeSpan>
            <sys:TimeSpan x:Key="firstTime">0:0:0</sys:TimeSpan>
            <sys:TimeSpan x:Key="updateInterval">0:0:0.500</sys:TimeSpan>

            <LinearGradientBrush x:Key="themeBackgroundBrush" StartPoint="0,0" EndPoint="0,1">
                <LinearGradientBrush.GradientStops>
                    <GradientStopCollection>
                        <GradientStop Color="#FFFFFF" Offset="0" />
                        <GradientStop Color="#CCCCCC" Offset="1" />
                    </GradientStopCollection>
                </LinearGradientBrush.GradientStops>
            </LinearGradientBrush>

            <SolidColorBrush Color="Black"  x:Key="UserConnectionsPen" />

            <LinearGradientBrush x:Key="UserConnectionsFill">
                <LinearGradientBrush.GradientStops>
                    <GradientStopCollection>
                        <GradientStop Color="#993333" Offset="0" />
                        <GradientStop Color="#440000" Offset="1" />
                    </GradientStopCollection>
                </LinearGradientBrush.GradientStops>
            </LinearGradientBrush>


        </ResourceDictionary>
    </UserControl.Resources>


    <ScrollViewer x:Name="scroll" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" 
                                  Margin="0,0,0,0" Padding="0" >

        <DockPanel>

            <ContentControl Margin="5" VerticalAlignment="Top" DockPanel.Dock="Top">
                <StackPanel>
                    <TextBlock Text="User Connections and Logins / Second" Margin="5" FontWeight="Bold"  />

                    <StackPanel Orientation="Horizontal">
                        <StackPanel Orientation="Vertical" Margin="10,0,10,0">
                            <TextBlock Text="Zoom" HorizontalAlignment="Center"  FontWeight="Bold" Margin="0,0,0,5"/>

                            <RepeatButton Name="btnZoomIn" Click="btnZoomIn_Click" MinWidth="16" Width="16" Margin="0,0,0,5" Cursor="Hand">
                                <RepeatButton.Template>
                                    <ControlTemplate>
                                        <Image Source="/SqlMim.SqlServer;component/Images/zoom_in.png" Width="16" Margin="0,0,1,-1" Cursor="Hand" ></Image>
                                    </ControlTemplate>
                                </RepeatButton.Template>
                            </RepeatButton>
                            <RepeatButton Name="btnZoomOut" Click="btnZoomOut_Click" MinWidth="16" Width="16" >
                                <RepeatButton.Template>
                                    <ControlTemplate>
                                        <Image Source="/SqlMim.SqlServer;component/Images/zoom_out.png" Width="16" Margin="0,0,1,-1"  ></Image>
                                    </ControlTemplate>
                                </RepeatButton.Template>
                            </RepeatButton>
                        </StackPanel>
                        <StackPanel Orientation="Vertical" >
                            <uc:HistoryGraph  GraphType="GraphMax" BorderBrush="Black" BorderThickness="1" Foreground="Black"
                                  GraphDuration="{StaticResource graphDuration}" Height="150" Width="250"  
                                  Name="userConnectionsGraph" 
                                  Background="{StaticResource themeBackgroundBrush}">

                                <!--<uc:HistoryGraph.ScrollInterval>
                                    <sys:TimeSpan>0:0:1</sys:TimeSpan>
                                </uc:HistoryGraph.ScrollInterval>-->

                                <!--AXE DES Y : Correspond à un axe de VALEURS-->

                                <!--Maximum des valeurs sur l'axe des Y . Valeur de départ. Est recalculé si GraphType != FixeMax -->
                                <!--<uc:HistoryGraph.YMaxValue>
                                <sys:Double>10</sys:Double>
                            </uc:HistoryGraph.YMaxValue>-->

                                <!--Interval majeur sur l'axe des Y : Dessine un grand trait + le label-->
                                <uc:HistoryGraph.MajorValueInterval>
                                    <sys:Int32>4</sys:Int32>
                                </uc:HistoryGraph.MajorValueInterval>


                                <!--Interval Mineur sur l'axe des Y : Dessine un petit trait-->
                                <uc:HistoryGraph.MinorValueInterval>
                                    <sys:Int32>1</sys:Int32>
                                </uc:HistoryGraph.MinorValueInterval>

                                <!--AXE DES X : Correspond à un axe de TEMPS écoulé -->

                                <!--Laps de temps avant le début : Interval de début : peut par exemple commencer 30 Secondes aprés le début-->
                                <uc:HistoryGraph.FirstTimeVisible>
                                    <StaticResource ResourceKey="firstTime" />
                                </uc:HistoryGraph.FirstTimeVisible>

                                <!--Intervalle majeur sur l'axe des X : Toutes les 30 secondes un grand trait + le label -->
                                <uc:HistoryGraph.MajorTimeInterval>
                                    <sys:TimeSpan>0:0:30</sys:TimeSpan>
                                </uc:HistoryGraph.MajorTimeInterval>

                                <!--Intervalle mineur sur l'axe des X : Toute les 5 secondes, un petit trait -->
                                <uc:HistoryGraph.MinorTimeInterval>
                                    <sys:TimeSpan>0:0:5</sys:TimeSpan>
                                </uc:HistoryGraph.MinorTimeInterval>

                                <!--Interval complet : Correspond au temps complet sur l'axe des X visible-->
                                <uc:HistoryGraph.VisibleInterval>
                                    <!--<Setter Property="VisibleInterval" Value="{Binding ElementName=_timeShownSlider, Path=Value, Converter={StaticResource timeConverter}}" />-->
                                    <Binding  ElementName="sliderUserConnections" Path="Value" Converter="{StaticResource TimeSpanConverter}" />
                                </uc:HistoryGraph.VisibleInterval>
                            </uc:HistoryGraph>
                            <Slider Orientation="Horizontal" Name="sliderUserConnections"  HorizontalAlignment="Stretch" Height="30" Width="218"
                                    Minimum="2" Maximum="179" Value="29" ></Slider>
                        </StackPanel>

                        <StackPanel Orientation="Vertical" Margin="10,0,0,0">

                            <TextBlock Text="Legend" HorizontalAlignment="Center"  FontWeight="Bold" Margin="0,0,0,5"/>

                            <StackPanel Orientation="Horizontal">
                                <Rectangle Width="30" Height="10"  Fill="{StaticResource UserConnectionsPen}"></Rectangle>
                                <TextBlock Text="User Connections" Margin="5,0,0,0" />
                            </StackPanel>

                            <StackPanel Orientation="Horizontal">
                                <Rectangle Width="30" Height="10"  Fill="{StaticResource UserConnectionsFill}"></Rectangle>
                                <TextBlock Text="Logins / Sec." Margin="5,0,0,0" />
                            </StackPanel>
                        </StackPanel>
                    </StackPanel>
                </StackPanel>
            </ContentControl>

            <ContentControl Margin="5" VerticalAlignment="Top" DockPanel.Dock="Top">
                <StackPanel>
                    <TextBlock Text="Other intereting things on my Server" Margin="5" FontWeight="Bold"  />

                    <StackPanel Orientation="Horizontal">
                        <StackPanel Orientation="Vertical" Margin="10,0,10,0">
                            <TextBlock Text="Zoom" HorizontalAlignment="Center"  FontWeight="Bold" Margin="0,0,0,5"/>

                            <RepeatButton MinWidth="16" Width="16" Margin="0,0,0,5" Cursor="Hand">
                                <RepeatButton.Template>
                                    <ControlTemplate>
                                        <Image Source="/SqlMim.SqlServer;component/Images/zoom_in.png" Width="16" Margin="0,0,1,-1" Cursor="Hand" ></Image>
                                    </ControlTemplate>
                                </RepeatButton.Template>
                            </RepeatButton>
                            <RepeatButton  MinWidth="16" Width="16" Cursor="Hand">
                                <RepeatButton.Template>
                                    <ControlTemplate>
                                        <Image Source="/SqlMim.SqlServer;component/Images/zoom_out.png" Width="16" Margin="0,0,1,-1"  ></Image>
                                    </ControlTemplate>
                                </RepeatButton.Template>
                            </RepeatButton>
                        </StackPanel>
                        <StackPanel Orientation="Vertical" >
                            <uc:HistoryGraph  GraphType="GraphMax" BorderBrush="Black" BorderThickness="1" Foreground="Black"
                                  GraphDuration="{StaticResource graphDuration}" Height="150" Width="250"  
                                  Background="{StaticResource themeBackgroundBrush}">

                                <!--<uc:HistoryGraph.ScrollInterval>
                                    <sys:TimeSpan>0:0:1</sys:TimeSpan>
                                </uc:HistoryGraph.ScrollInterval>-->

                                <!--AXE DES Y : Correspond à un axe de VALEURS-->

                                <!--Maximum des valeurs sur l'axe des Y . Valeur de départ. Est recalculé si GraphType != FixeMax -->
                                <!--<uc:HistoryGraph.YMaxValue>
                                <sys:Double>10</sys:Double>
                            </uc:HistoryGraph.YMaxValue>-->

                                <!--Interval majeur sur l'axe des Y : Dessine un grand trait + le label-->
                                <uc:HistoryGraph.MajorValueInterval>
                                    <sys:Int32>4</sys:Int32>
                                </uc:HistoryGraph.MajorValueInterval>


                                <!--Interval Mineur sur l'axe des Y : Dessine un petit trait-->
                                <uc:HistoryGraph.MinorValueInterval>
                                    <sys:Int32>1</sys:Int32>
                                </uc:HistoryGraph.MinorValueInterval>

                                <!--AXE DES X : Correspond à un axe de TEMPS écoulé -->

                                <!--Laps de temps avant le début : Interval de début : peut par exemple commencer 30 Secondes aprés le début-->
                                <uc:HistoryGraph.FirstTimeVisible>
                                    <StaticResource ResourceKey="firstTime" />
                                </uc:HistoryGraph.FirstTimeVisible>

                                <!--Intervalle majeur sur l'axe des X : Toutes les 30 secondes un grand trait + le label -->
                                <uc:HistoryGraph.MajorTimeInterval>
                                    <sys:TimeSpan>0:0:30</sys:TimeSpan>
                                </uc:HistoryGraph.MajorTimeInterval>

                                <!--Intervalle mineur sur l'axe des X : Toute les 5 secondes, un petit trait -->
                                <uc:HistoryGraph.MinorTimeInterval>
                                    <sys:TimeSpan>0:0:5</sys:TimeSpan>
                                </uc:HistoryGraph.MinorTimeInterval>

                                <!--Interval complet : Correspond au temps complet sur l'axe des X visible-->
                                <uc:HistoryGraph.VisibleInterval>
                                    <!--<Setter Property="VisibleInterval" Value="{Binding ElementName=_timeShownSlider, Path=Value, Converter={StaticResource timeConverter}}" />-->
                                    <Binding  ElementName="slider2" Path="Value" Converter="{StaticResource TimeSpanConverter}" />
                                </uc:HistoryGraph.VisibleInterval>
                            </uc:HistoryGraph>
                            <Slider Orientation="Horizontal" Name="slider2"  HorizontalAlignment="Stretch" Height="30" Width="218"
                                    Minimum="2" Maximum="179" Value="29" ></Slider>
                        </StackPanel>

                        <StackPanel Orientation="Vertical" Margin="10,0,0,0">

                            <TextBlock Text="Legend" HorizontalAlignment="Center"  FontWeight="Bold" Margin="0,0,0,5"/>

                            <StackPanel Orientation="Horizontal">
                                <Rectangle Width="30" Height="10"  Fill="{StaticResource UserConnectionsPen}"></Rectangle>
                                <TextBlock Text="bla bla bla ..." Margin="5,0,0,0" />
                            </StackPanel>

                            <StackPanel Orientation="Horizontal">
                                <Rectangle Width="30" Height="10"  Fill="{StaticResource UserConnectionsFill}"></Rectangle>
                                <TextBlock Text="bla bla bla ..." Margin="5,0,0,0" />
                            </StackPanel>
                        </StackPanel>
                    </StackPanel>
                </StackPanel>
            </ContentControl>

        </DockPanel>

    </ScrollViewer>

</UserControl>
